//主JS
$.navigation = $('nav > ul.nav');
$(document).ready(function($){
  // Dropdown Menu
  $.navigation.on('click', 'a', function(e){
    if ($.ajaxLoad) {
      e.preventDefault();
    }
    if ($(this).hasClass('nav-dropdown-toggle')) {
      $(this).parent().toggleClass('open');
      resizeBroadcast();
    }
  });
  function resizeBroadcast() {
    var timesRun = 0;
    var interval = setInterval(function(){
      timesRun += 1;
      if(timesRun === 5){
        clearInterval(interval);
      }
      if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
        var evt = document.createEvent('UIEvents');
        evt.initUIEvent('resize', true, false, window, 0);
        window.dispatchEvent(evt);
      } else {
      window.dispatchEvent(new Event('resize'));
      }
    }, 62.5);
  }
  /* ---------- Main Menu Open/Close, Min/Full ---------- */
  $('.sidebar-toggler').click(function(){
    $('.app-main').toggleClass('sidebar-hidden');
    resizeBroadcast();
  });
  $('.sidebar-minimizer').click(function(){
    $('.app-main').toggleClass('sidebar-minimized');
    resizeBroadcast();
  });
  $('.aside-menu-toggler').click(function(){
    $('.app-main').toggleClass('aside-menu-hidden');
    resizeBroadcast();
  });
  $('.mobile-sidebar-toggler').click(function(){
    $('.app-main').toggleClass('sidebar-mobile-show');
    resizeBroadcast();
  });
  $('.sidebar-close').click(function(){
    $('.app-main').toggleClass('sidebar-opened').parent().toggleClass('sidebar-opened');
  });
  /* ---------- Disable moving to top ---------- */
  $('a[href="#"][data-top!=true]').click(function(e){
    e.preventDefault();
  });
  //返回
  $("#goback").click(function(){
    window.history.go(-1);
  });
});
